class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode(int x) {
        val = x;
    }
}

class Solution {

    public boolean isSymmetric(TreeNode root) {
        if (root != null) {
            return recur(root.left, root.right);
        }
        return true;
    }

    private boolean recur(TreeNode node1, TreeNode node2) {
        if (node1 == null && node2 == null) return true;
        if (node1 == null || node2 == null || node1.val != node2.val) return false;
        return recur(node1.left, node2.right) && recur(node1.right, node2.left);
    }

    public static void main(String[] args) {
    }
}

